$(document).ready(function () {
    if (/MicroMessenger/.test(window.navigator.userAgent)) { //从微信进入支付
        $("#alipay").hide();
    }
});
$("input[type='radio']").click(function () {
    var val_r = $(this).val();
    $(".box_c_a").addClass("box_c_not");
    $(".box_c_a").removeClass("box_c_a");
    $(this).siblings().addClass("box_c_a");
    $(this).siblings().removeClass("box_c_not");
    if (val_r == 3) {
        $(".yinhangka").show()
    } else {
        $(".yinhangka").hide()
    }
});
$(".box_d_1").click(function () {
    var channelId = $("input[type='radio']:checked").val();//取到的value
    if (channelId == "0") {
        channelId = "ALIPAY_WAP";
    }
    if (channelId == "1") {
        if (/MicroMessenger/.test(window.navigator.userAgent)) { //从微信进入支付
            channelId = "WX_JSAPI";
        } else {
            channelId = "WX_MWEB";
        }
    }
	if (channelId == "2") {
        channelId="HL_ETH_PAY";
     var  remainPart=$("input[type='radio']:checked").attr('remainPart');
        if(remainPart<1){
            alert("ETH余额不足,请选择其他支付方式");
            return ;
        }
    }
    var referLink = document.createElement('a');
    referLink.href = "/createPayInfo?r="+Math.random()+"&channelId=" + channelId;//"ALIPAY_WAP";
    document.body.appendChild(referLink);
    referLink.click();
});
$(".close").click(function () {
    $(".box_e").hide();
    $(".box_e_5,#one,#two,#three,#four,#five,#sex").val("");
});
$(".copy").click(function () {
    if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) { //ios
        var Url2 = document.getElementById("yinhangka").innerText;
        var copyDOM = document.createElement('p');
        copyDOM.innerText = Url2;
        var element = document.getElementById("datas");
        element.appendChild(copyDOM);
        // var copyDOM = document.querySelector('#data');  //要复制文字的节点
        console.log(copyDOM);
        var range = document.createRange();
        // 选中需要复制的节点
        range.selectNode(copyDOM);
        // 执行选中元素
        window.getSelection().addRange(range);
        // 执行 copy 操作
        var successful = document.execCommand('copy');
        try {
            var msg = successful ? 'successful' : 'unsuccessful';

            console.log('copy is' + msg);
        } catch (err) {
            console.log('Oops, unable to copy');
        }
        // 移除选中的元素
        window.getSelection().removeAllRanges();
    } else {
        var Url2 = document.getElementById("yinhangka").innerText;
        var oInput = document.createElement('textarea');
        oInput.value = Url2;
        document.body.appendChild(oInput);
        oInput.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        document.body.removeChild(oInput);
    }
    alert("复制成功")
});
(function () {
    var container = document.getElementById("inputBoxContainer");
    boxInput = {
        maxLength: "",
        realInput: "",
        bogusInput: "",
        bogusInputArr: "",
        callback: "",
        init: function (fun) {
            var that = this;
            this.callback = fun;
            that.realInput = container.children[0];
            that.bogusInput = container.children[1];
            that.bogusInputArr = that.bogusInput.children;
            that.maxLength = that.bogusInputArr[0].getAttribute("maxlength");
            that.realInput.oninput = function () {
                that.setValue();
            }
            that.realInput.onpropertychange = function () {
                that.setValue();
            }
        },
        setValue: function () {
            this.realInput.value = this.realInput.value.replace(/\D/g, "");
            var real_str = this.realInput.value;
            for (var i = 0; i < this.maxLength; i++) {
                this.bogusInputArr[i].value = real_str[i] ? real_str[i] : "";
            }

            if (real_str.length == this.maxLength) {
                this.realInput.value = real_str.substring(0, 6);
                this.callback();
            }
        }, getBoxInputValue: function () {
            var realValue = "";
            console.log(this.bogusInputArr);
            for (var i in this.bogusInputArr) {
                if (!this.bogusInputArr[i].value) {
                    break;
                }
                if (parseInt(0) <= i && i <= parseInt(6)) {
                    realValue += this.bogusInputArr[i].value;
                }
            }
            return realValue;
        }
    }
})();